package cn.zhentao.service.impl;

import cn.zhentao.dao.AccountDao;
import cn.zhentao.service.AccountService;
import cn.zhentao.service.LogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class AccountServiceImpl implements AccountService {

    @Autowired
    private AccountDao dao;

    @Autowired
    private LogService logService;

    @Override
    public void transfer(String out, String in, Double money) {
       try{
           //先转出
           dao.outMoney(out,money);
           int i  = 1/0;
           //再转入
           dao.inMoney(in,money);
       }finally {
           logService.log(out,in,money);
       }
    }
}
